package movee.netconf.client;

import java.util.Arrays;
import java.util.List;

/**
 * @author Jonas Glass
 */
public class NetconfConstants {

    private NetconfConstants() {
    }

    /**
     * Device prompt for the framing protocol.
     * https://tools.ietf.org/html/rfc6242#section-4.1
     */
    public static final String DEVICE_PROMPT = "]]>]]>";

    /**
     * XML Schema prefix.
     */
    public static final String XML_VERSION = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";

    /**
     * XML Namespace for NETCONF Base 1.0
     * https://tools.ietf.org/html/rfc6241#section-8.1
     */
    public static final String URN_XML_NS_NETCONF_BASE_1_0 = "urn:ietf:params:xml:ns:netconf:base:1.0";

    /**
     * URN for NETCONF Base 1.0
     * https://tools.ietf.org/html/rfc6241#section-8.1
     */
    public static final String URN_IETF_PARAMS_NETCONF_BASE_1_0 = "urn:ietf:params:netconf:base:1.0";

    public static final String EMPTY_LINE = "";
    public static final String LF = "\n";
    public static final String CR = "\r";

    public static final String HUAWEI_CAPABILITY_ACTION_1_0 = "http://www.huawei.com/netconf/capability/action/1.0";

    public static final String HUAWEI_CAPABILITY_EXCHANGE_1_0 = "http://www.huawei.com/netconf/capability/exchange/1.0";

    public static final List<String> DEFAULT_CLIENT_CAPABILITIES = Arrays.asList(
            NetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0/*,
            NetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0 + "#candidate",
            NetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0 + "#confirmed-commit",
            NetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0 + "#validate",
            NetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0 + "#url?protocol=http,ftp,file"
            */
    );

    public static final String CISCO_HEARTBEAT_MESSAGE =
            "<nf:rpc xmlns:nf=\"urn:ietf:params:xml:ns:netconf:base:1.0\"       \n" +
                    "  xmlns=\"http://www.cisco.com/nxos:7.0.3.I4.1.:if_manager\" message-id=\"101\">\n" +
                    "  <nf:get>\n" +
                    "    <nf:filter type=\"subtree\">\n" +
                    "      <show>" +
                    "        <hostname/>" +
                    "      </show>\n" +
                    "    </nf:filter>\n" +
                    "  </nf:get>\n" +
                    "</nf:rpc>";

    public static final String H3C_HEARTBEAT_MESSAGE = "<rpc message-id=\"101\"\n" +
            "    xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
            "  <get>\n" +
            "    <filter type=\"subtree\">\n" +
            "      <top xmlns=\"http://www.h3c.com/netconf/data:1.0\">\n" +
            "        <Device>\n" +
            "          <Base>\n" +
            "            <HostName/>\n" +
            "          </Base>\n" +
            "        </Device>\n" +
            "      </top>\n" +
            "    </filter>\n" +
            "  </get>\n" +
            "</rpc>";

    public static final String HW_HEARTBEAT_MESSAGE =
            "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"101\">\n" +
                    "  <get>\n" +
                    "    <filter type=\"subtree\">\n" +
                    "      <system xmlns=\"http://www.huawei.com/netconf/vrp\" " +
                    "content-version=\"1.0\" format-version=\"1.0\">\n" +
                    "        <systemInfo>\n" +
                    "          <sysName/>\n" +
                    "       </systemInfo>\n" +
                    "      </system>\n" +
                    "    </filter>\n" +
                    "  </get>\n" +
                    "</rpc>\n";

    public static final String JUNIPER_HEARTBEAT_MESSAGE =
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                    "<rpc message-id=\"101\">\n" +
                    "  <get-config>\n" +
                    "    <source>\n" +
                    "      <running/>\n" +
                    "    </source>\n" +
                    "    <filter type=“subtree”>\n" +
                    "      <configuration>\n" +
                    "        <system>\n" +
                    "          <host-name/>\n" +
                    "        </system>\n" +
                    "     </configuration>\n" +
                    "    </filter>\n" +
                    "  </get-config>\n" +
                    "</rpc>";

    public static final String RUIJIE_HEARTBEAT_MESSAGE =
            "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                    "<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
                    "  <get>\n" +
                    "    <filter type=\"subtree\">\n" +
                    "      <system xmlns=\"http://openconfig.net/yang/system\">\n" +
                    "        <config>\n" +
                    "          <hostname/>\n" +
                    "        </config>\n" +
                    "        <state>\n" +
                    "          <hostname/>\n" +
                    "        </state>\n" +
                    "      </system>\n" +
                    "    </filter>\n" +
                    "  </get>\n" +
                    "</rpc>";

}
